<template>
  <section>
    <el-dialog
      title="提交审核"
      :visible.sync="open"
      width="500px"
      append-to-body
      @close="cancel"
      custom-class="audit-mode"
    >
      <Form
        :formData="formData"
        :rulesData="rulesData"
        :formBtns="formBtns"
        v-if="this.row.authType==='submit'?this.formData[1].options.length:this.formData[0].options.length"
        @handleSubmit="handleSubmit"
      />
    </el-dialog>
  </section>
</template>

<script>
import { Rule } from "@/utils/rule.js";
import Form from "@/components/form/index.vue";
import { vendorAuditOperatorAudit } from "@/api/collect/task/index";
export default {
  components: {
    Form,
  },
  props: {
    row: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      open: true,
      formData: [
        {
          prop: "nextAudit",
          type: "selectFilter",
          options: [],
          label: "下一节点审核",
          placeholder: "请输入下一节点审核",
          value: "",
        },
      ],
      formBtns: [
        //表单按钮
        {
          type: "primary",
          label: "保存",
          isVerify: true,
        },
        {
          label: "返回",
          click: () => {
            this.$emit("onBack", "isAudit");
          },
        },
      ],

      rulesData: {
        nextAudit: [
          Rule.checkDataNull("请输入下一节点审核", ["blur", "change"]),
        ],
      },
    };
  },

  mounted() {
    if (this.row.authType==='submit') {
      this.formData.unshift({
        prop: "nextAuditType",
        type: "checkbox",
        options: [
          { label: "复核人审核", value: 1 },
          { label: "科室负责人审核", value: 2 },
          { label: "分管中心领导审核", value: 3 },
        ],
        label: "科室负责人",
        placeholder: "请选择科室负责人",
        value: [1,2,3],
      });
    }
    this.getLoad();
  },
  methods: {
    //获取数据
    getLoad() {
      this.GetAuditUserList((data) => {
        data.forEach((item) => {
          item.label = item.userName;
          item.value = item.userId + "/" + item.userName;
        });
        console.log(11,data);
        if(this.row.authType==='submit'){
          this.formData[1].options = data;
          return;
        }
        this.formData[0].options = data;
      });
    },

    //保存
    handleSubmit(data) {
      this.$emit("onSuccess", data);
    },
    // 关闭模态框
    cancel() {
      this.$emit("onBack", "isAudit");
    },
  },
};
</script>

<style lang="scss">
@import "../../../assets/styles/collect.scss";
.audit-mode {
  .el-dialog__body {
    padding: 30px 20px 15px;
  }
  .form {
    margin-bottom: 0;
    .el-form-item {
      width: 95%;
      &:last-child {
        margin-bottom: 0 !important;
      }
    }
  }
}
</style>
